package org.jspar.place;

import org.jspar.model.Terminal;

public class ConnectionCounter implements IOutsideConnectionEnumerator {

	private int count = 0;

	public ConnectionCounter() {
		count = 0;
	}
	public int count() { return count; }

	public void terminalsDo(Terminal s, Terminal e) {

		/* count in-out connections */
		if ((s.isOut() || s.isInOut()) && (e.isIn() || e.isInOut()))
			count += 1;
				
		/* count out-out connections */
		if ((s.isOut() || s.isInOut()) && (e.isOut() || e.isInOut()))
			count += 1;
				
		/* count out-in connections */
		if ((s.isIn() || s.isInOut()) && (e.isOut() || e.isInOut()))
			count += 1;
						
		/* count in-in connections */
		if ((s.isIn() || s.isInOut()) && (e.isIn() || e.isInOut()))
			count += 1;
	}
}
